package com.qf.lja.servlet;

import com.qf.lja.dao.ProductDao;
import com.qf.lja.enity.Product;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet(urlPatterns = "/productInfo.do")
public class ProductInfoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Integer productId = Integer.parseInt(req.getParameter("p_id"));

        ProductDao productDao = new ProductDao();
        Product product = productDao.findByProductId(productId);

        req.setAttribute("product", product);
        req.getRequestDispatcher("/goodsDetail.jsp").forward(req, resp);
    }
}
